<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户注册</title>
<link rel="stylesheet" href="/skin/html.css" type="text/css" />
<link rel="stylesheet" href="/skin/sform.css" type="text/css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.validate.js"></script>
<style type="text/css">
.sform{width:800px;}
.sform .error{clear:both;display:block;}
.sform .inline label{width:14%;}
.sform .textput{width:38%;height:20px;color:#333}

.v-err{
    clear: none;
    color: #888888;
    float: right;
    font-size: 12px;
    width: 40%;
    color:red;
}
.v-suc{color:green;}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$('form.sform').find('input, select, textarea').not("#submit_bnt").focus(function(){
		$(this).parent().addClass("focus");
	}).blur(function(){
		$(this).parent().removeClass("focus");
	});


	 /**
	  * 验证执行
	  */
	  var validator = $("#regForm").validate({
        errorElement:"p",
        errorClass:"v-err",
		rules: {
			email: {
				required: true,
				email: true
			},
			password: {
				required: true,
				minlength:4
			},
			username: {
				required: true,
				minlength:2
			}
		},
		messages: {
			email: {
				required: "请输入邮箱地址",
				email: "邮箱格式错误"
			},
			password: {
				required: "请输入密码",
				minlength: "密码长度不能少于4位"
			},
			username: {
				required: "请取一个名字",
				minlength: "用户名长度不能少于2位"
			}
		},

		// 错误显示
        /*
		errorPlacement: function(error, element) {
			//errstr = error.html();
			//element.parent().find('p').addClass('error').html(error.html());
            element.parent().find('.tips').css({display:"none"});
			element.parent().append(error);
            //element.parent().find('.tips').css({color:"red"}).html(error.html());
            //element.removeClass("error");
		},
        */
		// 提交处理
		submitHandler: function() {
			$.ajax({
				type: "POST",
				url: "/account/doreg",
				data: "email="+ $("#email").val() +"&username="+ $("#username").val() +"&password="+ $("#password").val(),
				dataType: 'json',
				error: function(responseXML) {
					alert(responseXML.responseText);
				},
				success: function(result) {
					if (result.status == 1) {
                        alert('恭喜您注册成功！');
						window.location.href = "/my";
					} else {
						alert(result.message);
					}					
				}
			});
		},
		// 正确显示
        /*
		success: function(label) {
			label.addClass("tips").css({color:"green"}).text("正确");
		},
        */
		onkeyup:false
		//onfocusout:true
	  });
});
</script>
</head>
<body>
<!--头部_start-->
<div class="wrap" id="header">
    <div class="cleft"><img src="/skin/images/logo_3.gif" /></div>
    <div class="cright ralign">
        <a href="/account/register">注册</a>
    </div>
    <!--
    <div class="cright ralign">
		<form name="searchForm" id="searchForm" method="post" action="" onsubmit="return checkSearch(this)">
		<input type="text" name="skw" id="skw" class="textput" />
		<input type="submit" value="搜索" class="bnt-small" value="搜索" />
		</form>
    </div>-->
    <div class="clear"></div>
</div>
<!--头部结束_end-->

<!--主体_start-->
<div class="wrap">
<h1>用户注册</h1>
        <form name="regForm" id="regForm" method="post" action="/account/register" class="sform">
        <fieldset class="inline">
            <div class="field">
                <label for="email">常用邮箱：</label>
                <input type="text" name="email" class="textput" id="email" />
                <p class="tips">这个很重要</p>
            </div>
            <div class="field">
                <label for="upass">注册密码：</label>
                <input type="password" name="password" class="textput" id="password" />
                <p class="tips">最少4个字符，不要用中文</p>
            </div>
            <div class="field">
                <label for="uname">显示昵称：</label>
                <input type="text" name="username" class="textput" id="username" />
                <p class="tips">中英文都可以</p>
            </div>
            <div class="button">
                <input type="submit" value="提交注册" class="bnt-mid" id="submit_bnt" /><br /><br />
                <a href="/account/login">已有账号，点此登陆</a>
            </div>
        </fieldset>
        </form>
</div>
<!--主体_end-->

<!--页脚_start-->
<div id="footer" class="wrap">
    <div class="about">
    <ul>
        <li><a href="#about">About</a></li>
        <li><a href="#sitemap">SiteMap</a></li>
    </ul>
    </div>
    <div class="copy">mouxa.com&copy;shuky2000#163.com</div>
</div>
<!--页脚_end-->
</body>
</html>